#ifndef __ming_fyp_render_LoadingPolicy_h__
#define __ming_fyp_render_LoadingPolicy_h__

//------------------------------------------------------------------------------
// header includes

struct IDirect3DDevice9;
struct IDirect3DTexture9;
struct IDirect3DSurface9;
struct ID3DXEffect;
struct ID3DXMesh;

#include "fyp/core/Any.h"

//------------------------------------------------------------------------------
namespace ming
{
namespace fyp
{
namespace render
{
	//--------------------------------------------------------------------------
	class TBasicLoadingPolicy
	{
	public:
		TBasicLoadingPolicy(IDirect3DDevice9 *device);
		virtual ~TBasicLoadingPolicy();

	protected:
		IDirect3DDevice9 *mDevice;
	};

	//--------------------------------------------------------------------------
	class TD3DXMeshLoadingPolicy : public TBasicLoadingPolicy
	{
	public:
		TD3DXMeshLoadingPolicy(IDirect3DDevice9 *device) : TBasicLoadingPolicy(device) {}
		~TD3DXMeshLoadingPolicy() {}

		//------------------------------
		// external operations
		ID3DXMesh* Load(const char *filename, const Any &params);
		void Unload(ID3DXMesh *mesh);

	private:
		static bool msExportAscii;
		void ProcessMesh(ID3DXMesh *&mesh);
	};

	//--------------------------------------------------------------------------
	class TD3DXEffectLoadingPolicy : public TBasicLoadingPolicy
	{
	public:
		TD3DXEffectLoadingPolicy(IDirect3DDevice9 *device) : TBasicLoadingPolicy(device) {}

		//------------------------------
		// external operations
		ID3DXEffect* Load(const char *filename, const Any &params);
		void Unload(ID3DXEffect *effect);
	};

	//--------------------------------------------------------------------------
	class TD3DTextureLoadingPolicy : public TBasicLoadingPolicy
	{
	public:
		TD3DTextureLoadingPolicy(IDirect3DDevice9 *device) : TBasicLoadingPolicy(device) {}

		//------------------------------
		// external operations
		IDirect3DTexture9* Load(const char *filename, const Any &params);
		void Unload(IDirect3DTexture9 *texture);
	};

	//--------------------------------------------------------------------------
	class TD3DRenderedTextureLoadingPolicy : public TBasicLoadingPolicy
	{
	public:
		TD3DRenderedTextureLoadingPolicy(IDirect3DDevice9 *device) : TBasicLoadingPolicy(device) {}

		//------------------------------
		// external operations
		IDirect3DTexture9* Load(const char *filename, const Any &params);
		void Unload(IDirect3DTexture9 *texture);

	private:
		unsigned long Convert2D3dFormat(size_t fmt);
	};

	//--------------------------------------------------------------------------
	class TD3DDepthBufferLoadingPolicy : public TBasicLoadingPolicy
	{
	public:
		TD3DDepthBufferLoadingPolicy(IDirect3DDevice9 *device) : TBasicLoadingPolicy(device) {}

		//------------------------------
		// external operations
		IDirect3DSurface9* Load(const char *filename, const Any &params);
		void Unload(IDirect3DSurface9 *buf);

	private:
	};
	
	//--------------------------------------------------------------------------
}
}
}


#endif	//__ming_fyp_render_LoadingPolicy_h__